package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IDeleteEgnineeringOrderView;
import com.cloudsigns.factorymanager2.engineering.model.DeleteEngineeringOrderModel;
import com.cloudsigns.factorymanager2.engineering.model.IDeleteEngineeringOrderModel;

/**
 * Created by tony on 2018/4/5.
 */

public class DeleteEngineeringOrderPresenter {
    private IDeleteEgnineeringOrderView view;
    private IDeleteEngineeringOrderModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public DeleteEngineeringOrderPresenter(IDeleteEgnineeringOrderView view) {
        this.view = view;
        this.model = new DeleteEngineeringOrderModel();
    }

    public void deleteEngineeringOrder() {


        model.deleteEngineeringOrder(view.getEngineeringDeptOrderCategoryEnum(), view.getId(), new DeleteEngineeringOrderModel.OnDelteEngineeringOrderListener() {
            @Override
            public void deleteSuccessed() {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.deleteSunccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void deleteFailed(final String desc) {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.deleteEngineeringOrderFailed(desc);
                        view.hideLoading();
                    }
                });
            }
        });

    }
}
